import { Injectable } from '@nestjs/common';
import { CreateBetDto } from './dto/create-bet.dto';
import { UpdateBetDto } from './dto/update-bet.dto';
import { PrismaService } from 'src/prisma/prisma.service';

@Injectable()
export class BetService {
  constructor(private prisma: PrismaService) {}
  async createMany(createBetDtoArr: CreateBetDto[]) {
    return await this.prisma.bet.createMany({ data: createBetDtoArr });
  }

  async removeMany(id: number) {
    return await this.prisma.bet.deleteMany({ where: { zoneId: id } });
  }

  async findAll(args: Record<string, any>) {
    const { zoneId } = args;
    return await this.prisma.bet.findMany({
      where: { zoneId: +zoneId },
      include: {
        across: {
          select: {
            acrossName: true,
            acrossX: true,
            acrossY: true,
            controlHeight: true,
          },
        },
      },
    });
  }

  async findOne(id: number) {
    return await this.prisma.bet.findUnique({ where: { id } });
  }

  async update(id: number, updateBetDto: UpdateBetDto) {
    return this.prisma.bet.update({ where: { id }, data: updateBetDto });
  }

  remove(id: number) {
    return `This action removes a #${id} bet`;
  }
}
